package com.zj.cman.modules.articles.controller;

import com.zj.cman.modules.articles.entity.Article;
import com.zj.cman.modules.articles.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@RestController
@RequestMapping("/api/articles")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @PostMapping
    public void createArticle(@RequestBody Article article,
                              @RequestParam(required = false) Set<Long> categoryIds,
                              @RequestParam(required = false) Set<Long> tagIds) {
        articleService.saveArticleWithCategoriesAndTags(article, categoryIds, tagIds);
    }
}
